#include "Matrix.h"
#include "gtest-1.7.0/include/gtest/gtest.h"

TEST(Test1, Multiply_Test) {
	Matrix matrix1, matrix2, result;
	int input1[ORDER][ORDER] = {{6, -3, 5}, {2, 4, -4}, {9, -5, 6}};
	int input2[ORDER][ORDER] = {{7, 3, 8}, {3, 1, 2}, {6, 5, 9}};
	int output[ORDER][ORDER] = {{63, 40, 87}, {2, -10, -12}, {84, 52, 116}};
	matrix1.allocate();
	matrix2.allocate();
	matrix1.initialize(input1);
	matrix2.initialize(input2);
	result = matrix1.multiply(matrix2);
	for(int i=0; i<ORDER; i++)
		for(int j=0; j<ORDER; j++)
  			EXPECT_EQ(result.get(i, j), output[i][j]);
}

TEST(Test2, Addition_Test) {
	Matrix matrix1, matrix2, result;
	int input1[ORDER][ORDER] = {{2, 3, 6}, {5, -7, 4}, {4, 1, -8}};
	int input2[ORDER][ORDER] = {{3, 7, 2}, {2, 1, -5}, {8, 3, 1}};
	int output[ORDER][ORDER] = {{5, 10, 8}, {7, -6, -1}, {12, 4, -7}};
	matrix1.allocate();
	matrix2.allocate();
	matrix1.initialize(input1);
	matrix2.initialize(input2);
	result = matrix1.add(matrix2);
	for(int i=0; i<ORDER; i++)
		for(int j=0; j<ORDER; j++)
  			EXPECT_EQ(result.get(i, j), output[i][j]);
}

TEST(Test3, Multiply_And_Add_Test) {
	Matrix matrix1, matrix2, matrix3, result;
	int input1[ORDER][ORDER] = {{6, -3, 5}, {2, 4, -4}, {9, -5, 6}};
	int input2[ORDER][ORDER] = {{7, 3, 8}, {3, 1, 2}, {6, 5, 9}};
	int input3[ORDER][ORDER] = {{6, 2, 4}, {2, 4, 1}, {4, 8, 7}};
	int output[ORDER][ORDER] = {{69, 42, 91}, {4, -6, -11}, {88, 60, 123}};
	matrix1.allocate();
	matrix2.allocate();
	matrix3.allocate();
	matrix1.initialize(input1);
	matrix2.initialize(input2);
	matrix3.initialize(input3);
	result = matrix1.multiply(matrix2);
	result = result.add(matrix3);
	for(int i=0; i<ORDER; i++)
		for(int j=0; j<ORDER; j++)
  			EXPECT_EQ(result.get(i, j), output[i][j]);
}

TEST(Test4, Subtraction_Test) {
	Matrix matrix1, matrix2, result;
	int input1[ORDER][ORDER] = {{5, -3, 8}, {4, 7, 3}, {9, -1, -6}};
	int input2[ORDER][ORDER] = {{4, -7, 2}, {5, 1, 4}, {2, 8, 7}};
	int output[ORDER][ORDER] = {{1, 4, 6}, {-1, 6, -1}, {7, -9, -13}};
	matrix1.allocate();
	matrix2.allocate();
	matrix1.initialize(input1);
	matrix2.initialize(input2);
	result = matrix1.subtract(matrix2);
	for(int i=0; i<ORDER; i++)
		for(int j=0; j<ORDER; j++)
  			EXPECT_EQ(result.get(i, j), output[i][j]);
}